package com.qm.console.pubdef.constant.bx;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * //                       _oo0oo_
 * //                      o8888888o
 * //                      88" . "88
 * //                      (| -_- |)
 * //                      0\  =  /0
 * //                    ___/`---'\___
 * //                  .' \\|     |// '.
 * //                 / \\|||  :  |||// \
 * //                / _||||| -:- |||||- \
 * //               |   | \\\  -  /// |   |
 * //               | \_|  ''\---/''  |_/ |
 * //               \  .-\__  '-'  ___/-. /
 * //             ___'. .'  /--.--\  `. .'___
 * //          ."" '<  `.___\_<|>_/___.' >' "".
 * //         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 * //         \  \ `_.   \_ __\ /__ _/   .-` /  /
 * //     =====`-.____`.___ \_____/___.-`___.-'=====
 * //                       `=---='
 * //
 * //
 * //     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * //
 * //               佛祖保佑         永无BUG
 * <p>
 * com.qm.console.pubdef.constant.bx
 * Created on 2021/1/8.
 */
public enum BxAggregateMethod {

    Sum("sum", "加和"),
    Mean("mean", "平均值"),
    First("first", "按时间正序第一个值"),
    Last("last", "按时间正序最后一个值"),
    Nunique("nunique", "值的个数"),
    Count("count", "记录数量")

    ;
    public final String value;
    public final String desc;


    BxAggregateMethod(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static String fromMethod(String method) {
        return sMethods.get(method);
    }

    private static final HashMap<String, String> sMethods = new HashMap<>();

    static {
        sMethods.put(BxAggregateMethod.Sum.value, BxAggregateMethod.Sum.desc);
        sMethods.put(BxAggregateMethod.Mean.value, BxAggregateMethod.Mean.desc);
        sMethods.put(BxAggregateMethod.First.value, BxAggregateMethod.First.desc);
        sMethods.put(BxAggregateMethod.Last.value, BxAggregateMethod.Last.desc);
        sMethods.put(BxAggregateMethod.Nunique.value, BxAggregateMethod.Nunique.desc);
        sMethods.put(BxAggregateMethod.Count.value, BxAggregateMethod.Count.desc);
    }

    public static Map<String, String> aggregateMethods() {
        return new HashMap<>(sMethods);
    }
}
